package com.xike.micromemberserver.controller;

import com.xike.entiy.MemberEntity;
import com.xike.entiy.ResultBean;
import com.xike.micromemberserver.entity.Bookshelf;
import com.xike.micromemberserver.service.BookshelfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.LinkedList;

/**
 * (Bookshelf)表控制层
 *
 * @author makejava
 * @since 2021-04-29 09:34:33
 */
@Api("书架管理")
@RestController
@RequestMapping("/member/bookshelf")
public class BookshelfController {
    /**
     * 服务对象
     */
    @Resource
    private BookshelfService bookshelfService;

    /**
     * 通过主键查询单条数据
     *
     * @param
     * @return 单条数据
     */
    @ApiOperation("通过用户账号查询书架图书")
    @PostMapping("/selectByUser")
    public ResultBean selectByUser(@RequestBody MemberEntity memberEntity) {

        return bookshelfService.selectByUser(memberEntity.getUsername());
    }
    @ApiOperation("删除书架图书")
    @PostMapping("/deleteById")
    public ResultBean deleteById(@RequestBody Bookshelf bookshelf){
       return bookshelfService.deleteById(bookshelf.getId());
    }

    @ApiOperation("添加到书架")
    @PostMapping("/insertOne")
    public ResultBean insertOne(@RequestBody Bookshelf bookshelf){
        return bookshelfService.insertOne(bookshelf);
    }

}